package app.poi;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

/**
 * POI处理基类
 * 
 * TODO 简单的设置
 * @author zoe
 * 2016年6月2日
 */
public abstract class ABasePoiService {
	
	/**
	 * 设置源文件
	 * @return
	 */
	public abstract String setSourceFilePath();
	
	/**
	 * 设置目标目录
	 * @return
	 */
	public abstract String setTargetFileDirPath();
	
	/**
	 * 获取excel文件
	 * @return
	 * @throws FileNotFoundException
	 */
	public File getSourceFile() throws FileNotFoundException{
		return new File(setSourceFilePath());
	}
	
	/**
	 * 获取wb
	 * @return
	 * @throws FileNotFoundException
	 * @throws IOException
	 */
	public HSSFWorkbook getWorkbook() throws FileNotFoundException, IOException{
		return new HSSFWorkbook(new FileInputStream(getSourceFile()));
	}
	
	public void createTargetFileDir(String fileDirPath){
		File file = new File(fileDirPath);
		if(!file.exists()){
			file.mkdirs();
		}
	};

}
